''' <summary>
''' Provide access to the PDF encryption information
''' </summary>
''' <remarks>Exist only if the PDF file is encrypted (password protected)</remarks>
Public Class clsPdfEncryption
    Inherits clsPdfDictionnary
#Region "Private members"
    Private _hasUserRight As Boolean = False
    Private _userRights As Long
    Private _R As Long
#End Region
#Region "Constructors"
    Friend Sub New(ByVal dict As Hashtable)
        MyBase.New(dict)
        Dim obj As clsPdfBaseObject
        obj = MyBase.Item(PDF_P)
        If Not obj Is Nothing Then
            _hasUserRight = True
            _userRights = obj.GetLong
        End If
        obj = MyBase.Item(PDF_R)
        If Not obj Is Nothing Then
            _R = obj.GetLong
        End If
    End Sub
#End Region
#Region "Public Properties"
    ''' <summary>
    ''' Indicate if the PDF file has user's rights
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property HasUserRights() As Boolean
        Get
            HasUserRights = _hasUserRight
        End Get
    End Property
    ''' <summary>
    ''' Get the name of the preferred security handler for the PDF file
    ''' </summary>
    ''' <value></value>
    ''' <returns>Name of the preferred security</returns>
    ''' <remarks></remarks>
    Public ReadOnly Property Filter() As String
        Get
            Filter = MyBase.GetString(PDF_FILTER)
        End Get
    End Property
#End Region
#Region "Public Methods"
    ''' <summary>
    ''' Indicate if the user has the privilege for a specific access
    ''' </summary>
    ''' <param name="flag">The user access type</param>
    ''' <returns>True or False</returns>
    ''' <remarks></remarks>
    Public Function UserRight(ByVal flag As UserAccess) As Boolean
        If _hasUserRight Then
            UserRight = ((flag And _userRights) = flag)
        Else
            UserRight = True
        End If
    End Function
#End Region
End Class
